//
//  ViewController.m
//  Location的简单使用
//
//  Created by zpy on 15/12/5.
//  Copyright © 2015年 zpy. All rights reserved.
//

#import "ViewController.h"
#import <CoreLocation/CoreLocation.h>

@interface ViewController ()<CLLocationManagerDelegate>
// 位置管理器
@property(nonatomic,strong) CLLocationManager *locationmanager;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 1   创建位置管理器
    self.locationmanager = [[CLLocationManager alloc] init];
    // 2   请求用户授权  同时配置plist列表
    if ([self.locationmanager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
        [self.locationmanager requestWhenInUseAuthorization];
    }
    //设置代理 获取数据  翟男一枚
    self.locationmanager.delegate = self;
    // start
    [self.locationmanager startUpdatingLocation];
}
/**
 *  <#Description#>
 */
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
    CLLocation *location = locations.firstObject;
    
    NSLog(@"latitude: %f,longitude: %f",location.coordinate.latitude,location.coordinate.longitude);
    // 停止dingwi
    [self.locationmanager stopUpdatingLocation];
    
}


@end
